package servlet;

import pagination.PageBean;
import pojo.Brand;
import service.BrandService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "SelectByPageServlet", value = "/SelectByPageServlet")
public class SelectByPageServlet extends HttpServlet {
    BrandService brandService = new BrandService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String status = request.getParameter("status");
        String text = request.getParameter("text");
        //1. 调用BrandServicePage完成查询
        List<Brand> selectTotalCountByCondition = brandService.selectTotalCountByCondition(Integer.parseInt(status), text);
        //2. 存入request域中
        request.setAttribute("pageBeans",selectTotalCountByCondition);
        //3. 请求转发到brand.jsp
        request.getRequestDispatcher("/brand.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
